package com.administrator.kotlindemo1

import android.support.v7.widget.LinearLayoutManager
import com.administrator.kotlindemo1.adapter.MultiplePersonAdapter
import com.administrator.kotlindemo1.adapter.PersonAdapter
import com.administrator.kotlindemo1.bean.Person
import kotlinx.android.synthetic.main.activity_recycler.*

class RecyclerActivity : BaseActivity() {


    override fun initData() {
    }

    override fun initView() {
        var listPerson = arrayListOf<Person>()
        listPerson.add(Person("aa", 1, 0))
        listPerson.add(Person("bb", 2, 1))
        listPerson.add(Person("bb1",21,1))
        listPerson.add(Person("cc", 3, 2))
        listPerson.add(Person("dd", 4, 3))

        val personAdapter = PersonAdapter(this, listPerson, R.layout.person_list)
        val multiplePersonAdapter = MultiplePersonAdapter(this, listPerson)
        single_recycler.setOnClickListener({
            recycler.layoutManager = LinearLayoutManager(this)
            recycler.adapter = personAdapter

        })

        single_add.setOnClickListener({
            personAdapter.addData(Person("newData", 10, 0))
        })

        multiple_recycler.setOnClickListener({
            recycler.layoutManager = LinearLayoutManager(this)
            recycler.adapter = multiplePersonAdapter
        })

    }

    override fun start() {
    }

    override fun layoutId(): Int = R.layout.activity_recycler
}
